<?php #//AJAX PHP PENNY AUCTION v.2.0


#///////////////////////////////////////////////////////////
#//  COPYRIGHT 2009 Aaron Helmlinger ALL RIGHTS RESERVED  //
#///////////////////////////////////////////////////////////
                        include "../includes/config.inc.php";
       include "loggedin.inc.php";
         
$action = $_POST['action'];
 $startday = $_POST['startday'];
  $startmonth = $_POST['startmonth'];
  $startyear = $_POST['startyear'];
   $stopday = $_POST['stopday'];
  $stopmonth = $_POST['stopmonth'];
  $stopyear = $_POST['stopyear'];
  $reporttype = $_POST['reporttype'];
  
  if ( $action == 'update' ) {
  
  $startdate =  $startyear;
 $startdate .=  $startmonth; 
  $startdate .=  $startday;
  $startdate .=  "000000";
             
     $stopdate =  $stopyear;
 $stopdate .=  $stopmonth; 
  $stopdate .=  $stopday;
  $stopdate .=  "000000";
  
              if ( empty($stopday) ) {
              
              
 $stopdate =  $startyear;
 $stopdate .=  $startmonth;
 $stopdate .=  0; 
  $stopdate .=  $startday + 1;
  $stopdate .=  "000000";
              
              
$query = "SELECT * FROM PHPAUCTIONXL_payments WHERE itemtype='$reporttype' AND date>=$startdate AND date<=$stopdate AND amount>'0'";  

$result = mysql_query($query) or die(mysql_error());
                                                
              $query1 = "SELECT SUM(amount),AVG(amount) FROM PHPAUCTIONXL_payments WHERE itemtype='$reporttype' AND date>=$startdate AND date<=$stopdate AND amount>'0'";  


$result1 = mysql_query($query1) or die(mysql_error());
            
                
                
                                      }
         
                  if ( $stopday > 0 ) {
                  
                        $query = "SELECT * FROM PHPAUCTIONXL_payments WHERE itemtype='$reporttype' AND date>=$startdate AND date<=$stopdate AND amount>'0'";  


$result = mysql_query($query) or die(mysql_error());
                  
          $query1 = "SELECT SUM(amount),AVG(amount) FROM PHPAUCTIONXL_payments WHERE itemtype='$reporttype' AND date>=$startdate AND date<=$stopdate AND amount>'0'"; 
 

$result1 = mysql_query($query1) or die(mysql_error());

}
    }
      ?>
        <HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<link href="css/main.css" rel="stylesheet" type="text/css">
<SCRIPT Language=Javascript>
function window_open(pagina,titulo,ancho,largo,x,y){
        var Ventana= 'toolbar=0,location=0,directories=0,scrollbars=1,screenX='+x+',screenY='+y+',status=0,menubar=0,resizable=0,width='+ancho+',height='+largo;
        open(pagina,titulo,Ventana);
}
</SCRIPT>

</HEAD>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr> 
          <td class="icono"><img src="images/stats_icon2.gif" width="34" height="26" ></td>
          <td class="breadcrumbs">
         <p> <span><?=$MSG_AJAX_ADMIN_HEADING_REPORTS?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_5142?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
    <tr> 
    <td align="center" valign="middle">
<TABLE BORDER=0 WIDTH=95% CELLPADDING=0 CELLSPACING=0 BGCOLOR="#FFFFFF">
<TR>
<TD>
<CENTER>
    <BR>
    <FORM NAME=conf ACTION=<?=basename($_SERVER['PHP_SELF'])?> METHOD=POST>
        <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" class="base" style="border:1px solid #ccc;">
            <TR>
                <TD class="title">
                  <p>  <? print $MSG_AJAX_ADMIN_REPORTS_BUYNOW_PAYMENTS; ?></p>
                    </TD>
            </TR>
            <TR>
                <TD>
    <TABLE WIDTH=100% ALIGN="CENTER" CELLPADDING=0 cellspacing="0" BGCOLOR="#FFFFFF">
      <?
      if(isset($ERR))
      {
      ?>
      <TR>
        <TD COLSPAN="2" class="error"><p>
          <? print $ERR; ?>
          </p></TD>
      </TR>
      <?
      }
                     ?>
      <TR VALIGN="TOP">
           
 
<TD WIDTH="125"> 
					<p class="blue"></p>
					</TD>
					
					
				<TD WIDTH="405">
					
      
    <font color=red>Attention: Click the type of payment you want to see below.</font><BR>
     <BR>
     <a href=paymenthistoryauctions.php>[ Auctions ]</A>  
     <a href=paymenthistorybidpacks.php>[ Bid Packs ]</A>  
       <a href=paymenthistorybuynow.php>[ Buy Now ]</A>
       <a href=paymenthistoryall.php>[ ALL Combined ]</A><BR><BR> 
                 
        <font color=red>Attention: Select Start / Stop Date Range Below. Note: To Select A Single Date, Just Select A Start Date Only.</font><BR>
     <BR>
          
 <FORM NAME=conf ACTION=<?=basename($_SERVER['PHP_SELF'])?> METHOD=POST>        
         Start Date:
         
         <select name="startmonth" style="width:100px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">
 <option value=""><? print $REGISTER_PAGE_MONTH; ?></option> 
<option value=01>01 - <? print $REGISTER_PAGE_JANUARY; ?></option>
<option value=02>02 - <? print $REGISTER_PAGE_FEBRUARY; ?></option>
<option value=03>03 - <? print $REGISTER_PAGE_MARCH; ?></option>
<option value=04>04 - <? print $REGISTER_PAGE_APRIL; ?></option>
<option value=05>05 - <? print $REGISTER_PAGE_MAY; ?></option>
<option value=06>06 - <? print $REGISTER_PAGE_JUNE; ?></option>
<option value=07>07 - <? print $REGISTER_PAGE_JULY; ?></option>
<option value=08>08 - <? print $REGISTER_PAGE_AUGUST; ?></option>
<option value=09>09 - <? print $REGISTER_PAGE_SEPTEMBER; ?></option>
<option value=10>10 - <? print $REGISTER_PAGE_OCTOBER; ?></option>
<option value=11>11 - <? print $REGISTER_PAGE_NOVEMBER; ?></option>
<option value=12>12 - <? print $REGISTER_PAGE_DECEMBER; ?></option>
						</select>
            
             
						<select name="startday" style="width:60px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">

  <option value=""><? print $REGISTER_PAGE_DAY; ?></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

						</select> 
						
						
						
						
<SELECT NAME="startyear" style="width:80px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">
 <option value=""><? print $REGISTER_PAGE_YEAR; ?></option> 
<OPTION VALUE=2011>2011
<OPTION VALUE=2012>2012
<OPTION VALUE=2013>2013
<OPTION VALUE=2014>2014
<OPTION VALUE=2015>2015

</SELECT><BR><BR>

      Stop Date:   <select name="stopmonth" style="width:100px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">
 <option value=""><? print $REGISTER_PAGE_MONTH; ?></option> 
<option value=01>01 - <? print $REGISTER_PAGE_JANUARY; ?></option>
<option value=02>02 - <? print $REGISTER_PAGE_FEBRUARY; ?></option>
<option value=03>03 - <? print $REGISTER_PAGE_MARCH; ?></option>
<option value=04>04 - <? print $REGISTER_PAGE_APRIL; ?></option>
<option value=05>05 - <? print $REGISTER_PAGE_MAY; ?></option>
<option value=06>06 - <? print $REGISTER_PAGE_JUNE; ?></option>
<option value=07>07 - <? print $REGISTER_PAGE_JULY; ?></option>
<option value=08>08 - <? print $REGISTER_PAGE_AUGUST; ?></option>
<option value=09>09 - <? print $REGISTER_PAGE_SEPTEMBER; ?></option>
<option value=10>10 - <? print $REGISTER_PAGE_OCTOBER; ?></option>
<option value=11>11 - <? print $REGISTER_PAGE_NOVEMBER; ?></option>
<option value=12>12 - <? print $REGISTER_PAGE_DECEMBER; ?></option>
						</select>
            
             
						<select name="stopday" style="width:60px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">

  <option value=""><? print $REGISTER_PAGE_DAY; ?></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

						</select> 
						
						
						
						
<SELECT NAME="stopyear" style="width:80px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#000000;">
 <option value=""><? print $REGISTER_PAGE_YEAR; ?></option> 
<OPTION VALUE=2011>2011
<OPTION VALUE=2012>2012
<OPTION VALUE=2013>2013
<OPTION VALUE=2014>2014
<OPTION VALUE=2015>2015

</SELECT>
        <BR><BR> 
        <input type="hidden" name="reporttype" value="BuyNow-Item-ID">
<input type="hidden" name="action" value="update">
 <input type="submit" name="act" value="Run Report" class="action">
<Form>

               <BR><BR>
<h1>Buy Now Payments Report</h1>
 
 
 <? 
    echo "Start Date:".$startdate." - End Date:".$stopdate."<BR><BR>"; 
      print " PaymentID# - Payment Date / Time - Paymemt Amount - Auction ID - Auction Title<BR>";

      if ($result) {
while($row = mysql_fetch_array($result)){
     $counter++;
              
                  $bidid=$row['id'];
               $bidwhen=$row['date'];
               $bid = $row['amount'];
                $auctionid = $row['itemid'];
                  $auctiontitle = $row['itemname'];
                
          
    print "$counter) $bidid - $bidwhen - $bid - $auctionid - $auctiontitle<BR>";
     
   
    
	
	
	  
	
}     
     
              $row1 = mysql_fetch_array($result1);
              $sum = $row1['SUM(amount)'];
                    $avg = round($row1['AVG(amount)'],2);
     }
        print "<BR><BR>Total: $sum<BR><BR>Average: $avg";
     
          
    ?>      
     <BR><BR><font color=red>NOTE: These reports are for secondary reference only and may contain errors.<BR> Please refer to your payment gateway record located at your payment gateway provider for primary reference.
         </font>  </TD>
			</TR>
          
    </TABLE>
    </TD>
    </TR>
    </TABLE>
    </FORM>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>





 
 
 
 
 
 


